package com.itheima.edu.info.manager.sercive;

import com.itheima.edu.info.manager.dao.TeacherDao;
import com.itheima.edu.info.manager.domain.Student;
import com.itheima.edu.info.manager.domain.Teacher;

public class TeacherService {
    TeacherDao teacherDao = new TeacherDao();
    //判断id是否存在
    public boolean isExists(String id) {
        //查询所有
      Teacher[] teachers = teacherDao.finadAllTeacher();
      boolean flag=false;
        for (int i = 0; i < teachers.length; i++) {
            Teacher stu = teachers[i];
            if (stu!=null){
                if (stu.getId().equals(id)){
                   flag=true;
             }
            }
        }
        return flag;
    }

    public boolean addTeacher(Teacher teacher) {
        boolean b = teacherDao.addTeacher(teacher);

        return b;
    }
    //查询所有
    public Teacher[] findAllTeacher() {
        Teacher[] teachers = teacherDao.finadAllTeacher();
        return teachers;

    }
}
